{% set pypi_name = 'os-brick' %}
{% set upstream_version = upstream_version('4.1.0') %}
{% set rpm_release = '1' %}
{% set source = url_pypi() %}
# NOTE(ykarel): This is required to prevent singlespec macros from changing the requires
%global oldpython python
Name:           {{ py2name() }}
Version:        {{ py2rpmversion() }}
Release:        {{ py2rpmrelease() }}
Summary:        OpenStack Cinder brick library for managing local volume attaches
License:        {{ license('Apache-2.0') }}
Group:          Development/Languages/Python
URL:            https://docs.openstack.org/{{ pypi_name }}
Source0:        {{ source }}
BuildRequires:  openstack-macros
BuildRequires:  {{ py3('Babel') }}
BuildRequires:  {{ py3('castellan') }}
BuildRequires:  {{ py3('ddt') }}
BuildRequires:  {{ py3('eventlet') }}
BuildRequires:  {{ py3('os-win') }}
BuildRequires:  {{ py3('oslo.concurrency') }}
BuildRequires:  {{ py3('oslo.i18n') }}
BuildRequires:  {{ py3('oslo.log') }}
BuildRequires:  {{ py3('oslo.privsep') }}
BuildRequires:  {{ py3('oslo.service') }}
BuildRequires:  {{ py3('oslo.utils') }}
BuildRequires:  {{ py3('oslo.vmware') }}
BuildRequires:  {{ py3('oslotest') }}
BuildRequires:  {{ py3('pbr') }}
BuildRequires:  {{ py3('python-subunit') }}
BuildRequires:  {{ py3('reno') }}
BuildRequires:  {{ py3('requests') }}
BuildRequires:  {{ py3('six') }}
BuildRequires:  {{ py3('stestr') }}
BuildRequires:  {{ py3('tenacity') }}
BuildRequires:  {{ py3('testscenarios') }}
BuildRequires:  {{ py3('testtools') }}
BuildArch:      noarch

%description
OpenStack Cinder brick library for managing local volume attaches.
Features:
- Discovery of volumes being attached to a host for many transport protocols.
- Removal of volumes from a host.

%package -n python3-os-brick
Summary:        OpenStack Cinder brick library for managing local volume attaches
Requires:       %{oldpython}-os-brick-common
Requires:       {{ py3('Babel') }}
Requires:       {{ py3('eventlet') }}
Requires:       {{ py3('os-win') }}
Requires:       {{ py3('oslo.concurrency') }}
Requires:       {{ py3('oslo.i18n') }}
Requires:       {{ py3('oslo.log') }}
Requires:       {{ py3('oslo.privsep') }}
Requires:       {{ py3('oslo.service') }}
Requires:       {{ py3('oslo.utils') }}
Requires:       {{ py3('requests') }}
Requires:       {{ py3('six') }}
Requires:       {{ py3('tenacity') }}

%description -n python3-os-brick
OpenStack Cinder brick library for managing local volume attaches.
Features:
- Discovery of volumes being attached to a host for many transport protocols.
- Removal of volumes from a host.

This package contains the PYthon 3.x module.

%package -n {{ py2name() }}-doc
Summary:        Documentation for OpenStack os-brick library
BuildRequires:  {{ py3('Sphinx') }}
BuildRequires:  {{ py3('openstackdocstheme') }}

%description -n {{ py2name() }}-doc
OpenStack Cinder brick library for managing local volume attaches.
Features:
- Discovery of volumes being attached to a host for many transport protocols.
- Removal of volumes from a host.
This package contains the documentation.

%package -n python-os-brick-common
Summary:        Common files for the OpenStack Cinder brick library

%description -n python-os-brick-common
Configuration files for the OpenStack Cinder brick library.

%prep
%autosetup -p1 -n {{ pypi_name }}-{{ upstream_version }}
%py_req_cleanup

%build
%{py3_build}

# generate html docs
PBR_VERSION=%{version} %sphinx_build -b html doc/source doc/build/html
# remove the sphinx-build leftovers
rm -rf doc/build/html/.{doctrees,buildinfo}

%install
%{py3_install}

# move usr/etc to etc
mv %{buildroot}%{_prefix}%{_sysconfdir}/* %{buildroot}/%{_sysconfdir}/

%check
python3 -m stestr.cli run --concurrency=1

%files -n python3-os-brick
%license LICENSE
%doc README.rst ChangeLog
%{python3_sitelib}/os_brick
%{python3_sitelib}/*.egg-info

%files -n python-os-brick-common
%license LICENSE
%dir %{_sysconfdir}/rootwrap.d
%{_sysconfdir}/rootwrap.d/os-brick.filters

%files -n {{ py2name() }}-doc
%license LICENSE
%doc doc/build/html

%changelog
